<template>
  <div class="auditEnterprises">
    <div>
      <div class="title">
        <h1 style="color: #4D7181;font-size: 40px">审核宣讲会</h1>
        <div>
          <TagsOutlined class="icon"/>
          <AimOutlined class="icon"/>
        </div>

      </div>
    </div>
    <div style="border: 2px solid #4D7181; padding: 20px;border-top: 30px solid #4D7181; border-radius: 20px">

      <a-table :columns="columns" :data-source="dataSource" bordered>
        <template #bodyCell="{ column, text, record }">
          <template v-if="column.dataIndex === 'name'">
            <div class="editable-cell">
              <div v-if="editableData[record.key]" class="editable-cell-input-wrapper">
                <a-input v-model:value="editableData[record.key].name" @pressEnter="save(record.key)"/>
                <check-outlined class="editable-cell-icon-check" @click="save(record.key)"/>
              </div>
              <div v-else class="editable-cell-text-wrapper">
                {{ text || ' ' }}
                <edit-outlined class="editable-cell-icon" @click="edit(record.key)"/>
              </div>
            </div>
          </template>
          <template v-else-if="column.dataIndex === 'operation'">


          <router-link :to="{path:'/admin/video/info/'+record.videoId}">
            <a-button class="a-button" style="color: white;background-color: #67C23A" >去审核</a-button>
          </router-link>



          </template>
        </template>
      </a-table>
    </div>
  </div>

</template>
<script setup>
import {TagsOutlined,AimOutlined, EditOutlined} from '@ant-design/icons-vue';
import { onMounted, reactive, ref} from 'vue';
import {cloneDeep} from 'lodash-es';
import {pageVideoAPI} from "@/apis/video.js";

const columns = [
  {
    title: '宣讲会名称',
    dataIndex: 'videoName',
  },
  {
    title: '审核状态',
    dataIndex: 'videoCertificationStatus',
  },
  {
    title: '宣讲会状态',
    dataIndex: 'videoStatus',
  },
  {
    title: '公司名称',
    dataIndex: 'videoCompanyName',
  },
  {
    title: '操作',
    dataIndex: 'operation',
  },
];
const dataSource = ref();
const editableData = reactive({});
const edit = key => {
  editableData[key] = cloneDeep(dataSource.value.filter(item => key === item.key)[0]);
};
const save = key => {
  Object.assign(dataSource.value.filter(item => key === item.key)[0], editableData[key]);
  delete editableData[key];
};


//获取数据
const data = ref({pageCurrent: 1, pageSize: 10,videoCertificationStatus:"审核中"});
const getData = async (data) => {

  const res = await pageVideoAPI(data)
  dataSource.value = res.data.data.data;
  console.log(res)
  console.log("分页信息：" + JSON.stringify(res.data.data.data));
}

//生命周期
onMounted(() => {
  getData(data.value);
});
</script>


<style lang="scss" scoped>
.auditEnterprises {
  margin: 5px;
  padding: 20px 50px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 6px 20px rgba(0, 0, 0, 0.1);
  border-radius: 30px; /* 你可以调整这个值来改变圆角的大小 */

  .title {
    display: flex;
    justify-content: space-between;

    .icon {
      font-size: 35px;
      padding: 15px;
      color: white;
      margin-right: 20px;
      background-color: #C09E66;
      border-radius: 50px;
      margin-bottom: 10px;
    }
  }
  .a-button {
    margin-left: 10px;
  }
}


.highlight {
  background-color: rgb(255, 192, 105);
}

.editable-cell {
  position: relative;

  .editable-cell-input-wrapper,
  .editable-cell-text-wrapper {
    padding-right: 24px;
  }

  .editable-cell-text-wrapper {
    padding: 5px 24px 5px 5px;
  }

  .editable-cell-icon,
  .editable-cell-icon-check {
    position: absolute;
    right: 0;
    width: 20px;
    cursor: pointer;
  }

  .editable-cell-icon {
    margin-top: 4px;
    display: none;
  }

  .editable-cell-icon-check {
    line-height: 28px;
  }

  .editable-cell-icon:hover,
  .editable-cell-icon-check:hover {
    color: #108ee9;
  }

  .editable-add-btn {
    margin-bottom: 8px;
  }
}

.editable-cell:hover .editable-cell-icon {
  display: inline-block;
}
</style>